# from stone_cnc.realtime.processdata import  read_process_data, write_process_data
def write_process_data(name, value):
    pass


def read_process_data(name, value):
    pass


class BasicIo:
    def __init__(self, io_param_name):
        self.io_param_name = io_param_name

    def set_true(self):
        write_process_data(self.io_param_name, {"VALUE": True})

    def set_false(self):
        write_process_data(self.io_param_name, {"VALUE": False})

    def read_state(self):
        result = read_process_data(self.io_param_name)
        return result["VALUE"]


class BoolArrayIo:
    def __init__(self, io_param_name, array_size):
        if array_size == 0:
            raise RuntimeError("array_size can't be 0, you can use BasicIo for single bool io")
        self.io_param_name = io_param_name
        self.bool_values = [False for i in range(array_size)]

    def set_true(self, index):
        self.bool_values[index] = True
        write_process_data(self.io_param_name, {"VALUES": self.bool_values})

    def set_false(self, index):
        self.bool_values[index] = False
        write_process_data(self.io_param_name, {"VALUES": self.bool_values})

    def read_states(self):
        result = read_process_data(self.io_param_name)
        return result["VALUES"]

# class BasicIoMultiChannel(BasicIo):
#     def __init__(self, io_param_name, channel_index = None):
#         if channel_index is None:
#             super(BasicIoMultiChannel, self).__init__(io_param_name)
#         else:
#             super(BasicIoMultiChannel, self).__init__("{}_ch{}".format(io_param_name, channel_index))
#
#
#
# class LightIo(BasicIoMultiChannel):
#     """
#     开关灯io
#     """
#     def __init__(self, channel_index = None):
#         super(LightIo, self).__init__("LightIo", channel_index)
#
# class LubricationIo(BasicIoMultiChannel):
#     """
#     润滑开关io
#     """
#     def __init__(self, channel_index = None):
#         super(LubricationIo, self).__init__("LubricationIo", channel_index)
#
# class OilIo(BasicIoMultiChannel):
#     """
#     油压io
#     """
#     def __init__(self, channel_index = None):
#         super(OilIo, self).__init__("OilIo", channel_index)
